package com.example;

import android.databinding.DataBindingUtil;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.*;
import android.view.View;

import com.example.databinding.ActivityObservableExampleBinding;


public class ObservableExampleActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        ActivityObservableExampleBinding binding = DataBindingUtil.setContentView(this, R.layout.activity_observable_example);
        final ObservableUser user = new ObservableUser();
        user.setFirstName("ii");
        user.setLastName("ii");
        binding.setUser(user);
        binding.button.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                user.setFirstName("changed to xx");
                user.age.set(27);
                user.grades.put("english", "55");
            }
        });
    }
}
